<?php

/**
 * @author Laurent SITTLER <lolo.sittler@gmail.com>
 * @author Alexandre GOMEZ <gomez.alexandre02@gmail.com>
 * @version 0.1
 */

/**
 * Utils Class
 */
class Utils {

    /**
     * Constructor
     */
    function __construct() {
        
    }

    /**
     * Convert Bytes to Octets
     * @param Integer $bytes
     * @param Integer $precision
     * @return Integer in Octets
     */
    public static function bytesToSize($bytes, $precision = 2) {
        $unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');

        return @round(
                        $bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision
                ) . ' ' . $unit[$i];
    }

}